package cn.com.agree.contractcenter.infrastructure.contracttemplate.supportImpl.repositoryImpl;

import cn.com.agree.contractcenter.domain.contracttemplate.entity.ContractTemplate;
import cn.com.agree.contractcenter.domain.contracttemplate.support.repository.ContractTemplateRepository;
import cn.com.agree.contractcenter.infrastructure.contracttemplate.mapper.ContractTemplateMapper;
import cn.com.agree.contractcenter.infrastructure.contracttemplate.mapper.converter.ContractTemplateConverter;
import cn.com.agree.contractcenter.infrastructure.contracttemplate.mapper.po.ContractTemplatePO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * @author chenrui
 * @description
 * @date 2022/10/12
 */
@Repository
public class ContractTemplateRepositoryImpl implements ContractTemplateRepository {

    @Autowired
    private ContractTemplateMapper contractTemplateMapper;

    @Autowired
    private ContractTemplateConverter contractTemplateConverter;

    @Override
    public void saveContractTemplate(ContractTemplate contractTemplate) {
        ContractTemplatePO contractTemplatePO = contractTemplateConverter.toPO(contractTemplate);
        contractTemplateMapper.insert(contractTemplatePO);
    }

    @Override
    public ContractTemplate findContractTemplateById(Integer id) {
        ContractTemplatePO contractTemplatePO = contractTemplateMapper.selectById(id);
        return contractTemplateConverter.toEntity(contractTemplatePO);
    }
}
